package controllerLayer;
import modelLayer.*;
import java.util.*;

/**
 * Write a description of class LoanCTR here.
 * 
 * @author 
 * @version (a version number or a date)
 */
public class LoanCTR
{
    // instance variables - replace the example below with your own
    public void createLoan(int id, String borrowDate,int period, String state, Person person, Copy copy, DVD dvd)
    { Loan l=new Loan(id,borrowDate,period,state,person,copy,dvd);
        LoanContainer.getInstance().addLoan(l);
    
    }
    public Loan findLoan(int id)
    {
        return LoanContainer.getInstance().getLoan(id);

    }
    public void delete(int id){
        Loan l=findLoan(id);
        l.getCopy().setIsTaken(false);
        LoanContainer.getInstance().deleteLoan(l);
        System.out.println("Copy now available!");
    }
    public void printLoan(int id)
    {
        Loan l=findLoan(id);
        l.showLoan();
    }
    public void printLoans()
    {
        LoanContainer.getInstance().showAll();
    }
    public Copy checkCopy(DVD dvd)
    {
        return dvd.checkCopy();
    }
}
